package com.tedu.springmvc.controller;

import com.tedu.springmvc.mapper.UserInfoMapper;
import com.tedu.springmvc.pojo.dto.UserDTO;
import com.tedu.springmvc.pojo.entity.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {
    @Autowired
    private UserInfoMapper userInfoMapper;

    @RequestMapping("/regUser")
    @ResponseBody
    public String reg(UserDTO userDTO){
        System.out.println(userDTO);

        UserInfo userInfo = new UserInfo();
        userInfo.setUsername(userDTO.getUsername());
        userInfo.setPassword(userDTO.getPassword());
        userInfo.setNickname(userDTO.getNickname());
        userInfo.setAge(userDTO.getAge());
        int num = userInfoMapper.insetUser(userInfo);

        return num>0?"埋进坑里了ψ(｀∇´)ψ":"诈尸跑了Σ(っ °Д °;)っ";
    }
//    public String reg(HttpServletRequest request){
//        System.out.println("开始刨坑埋孩子");
//        String username = request.getParameter("username");
//        String password = request.getParameter("password");
//        String nickname = request.getParameter("nickname");
//        String age = request.getParameter("age");
//        System.out.println("username="+username+",password="+password+",nickname="+nickname+",age="+age);
//        return "埋进坑里了";
//    }
}
